/*
 * This file is part of Shopping Lists Organizer software
 *
 * Copyright (C) 2011 Denis Kvita <dkvita@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#include <QtGui>
#include <QtSql>

#include "shoppinglistmw.h"
#include "listsstore.h"

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	a.setApplicationName("shoppingList");

	QString loc = QLocale::system().name();
	QTranslator translator;
	translator.load(a.applicationDirPath()+"/translations/"+QString("shoppingList_")+loc);
	a.installTranslator(&translator);

	bool portable= true;
	if(argc==2 && QLatin1String(argv[1])=="-standalone") portable= false;

	a.setProperty("dataDir",(portable ? "." : QDesktopServices::storageLocation(QDesktopServices::DataLocation) ) );

	QString pwd;
	shoppingListMW *w= new shoppingListMW(pwd);
	w->show();

	int ret= a.exec();
	delete w;

	// close lists store and encrypt it if needed
	listsStore::close(pwd);

	return ret;
}
